///
/// This method inserts a new record into the table.
/// Start a transaction before calling this function.
///
public static void AddRecord()
{
// Set up the record object.
${${Table Name}RecordClassName} rec = new ${${Table Name}RecordClassName}();
//Set the fields of the new record as follows.
rec.${Field Name} = "1";
// Set values of other required fields here.
// Save the new record.
// Save adds the record to the database but commit
// happens when the page has completed its processing
rec.Save();
//Example shown below calls AddRecord() function on a button click.
//Note that you need to add transaction handling as shown below.
// public override void Button_Click( object sender, EventArgs args)
// {
// try
// {
// DbUtils.StartTransaction();
// OrdersRecord.AddRecord();
// DbUtils.CommitTransaction();
// this.DataChanged = true;
// }
// catch(Exception ex)
// {
// DbUtils.RollBackTransaction();
// BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "UNIQUE_SCRIPTKEY", ex.Message);
// }
// finally
// {
// DbUtils.EndTransaction();
// }
// }
}
|